<?php
/**
 * Created by PhpStorm.
 * User: 晶晶
 * Date: 2018/2/28
 * Time: 9:22
 */
require_once "admin_header.php";
$conn = mysql_connect("182.254.129.182", "root", "mojitoweilianda318", true);
mysql_select_db("marlboro_wanmi", $conn);

//限制
$sql = "select * from huggies_admin WHERE openid='$openid' AND status=1";
$ret = mysql_query($sql,$conn);

if (!is_resource($ret) || mysql_num_rows($ret) == 0) {
	echo "<h1>您没有权限哦~</h1>";
	exit();
}

$sql = "select name from bs_integral_store_next_config";
$ret = mysql_query($sql,$conn);
$count = array();
while($row = mysql_fetch_assoc($ret)){
    $prizeName = $row['name'];
	$count[$prizeName] = 0;
}

$sql = "select count(1) as count,prize_name from bs_integral_store_next_user group by prize";
$ret = mysql_query($sql,$conn);

while($row = mysql_fetch_assoc($ret)){
    $prizeName = $row['prize_name'];
	$count[$prizeName] = $row['count'];
}
$conn_pv = mysql_connect("182.254.129.182", "root", "mojitoweilianda318", true);
mysql_select_db("wanmi_pv_log", $conn_pv);
$query = "SELECT count(1) count FROM urls_pv_log where urlID='wanmi_istore_next_index.php'";
$pv = mysql_fetch_assoc(mysql_query($query,$conn_pv))['count'];
$query = "SELECT count(1) count FROM (SELECT count(1) count FROM urls_pv_log where urlID='wanmi_istore_next_index.php' GROUP BY visitWeixinID)a";
$uv = mysql_fetch_assoc(mysql_query($query,$conn_pv))['count'];
$user = $pv."/".$uv;

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="format-detection" content="telephone=no,email=no"/>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/style.css">
    <script type="text/javascript" src="../js/responsive.js"></script>
    <script type="text/javascript" src="../js/jquery-2.1.3.min.js"></script>
    <script type="text/javascript" src="../js/jquery.bpopup.js"></script>
    <title>万迷聚乐部</title>
    <style>
        .admin{
            background: #f7f7f7;
        }
        .row{
            background: #fff;
            margin-bottom: 0.5rem;
        }
        .row .title{
            padding: 1rem 1rem 0;
            font-size: 1.2rem;
            color: #000;
        }
        .box{
            display: -webkit-flex;
            display: -moz-flex;
            display: -o-flex;
            display: -ms-flex;
            display: flex;
            align-items: flex-start;
            justify-content: space-around;
            padding: 0.5rem;
        }
        .box .item{
            border: 1px solid #e2e2e2;
            padding: 0.5rem 0.5rem;
            height: 15.5rem;
            width: 49%;
        }
        .box .item p{
            color: #555;
            font-size: 0.8rem;
        }
        .box .item span{
            color: #000;
            font-size: 1rem;
        }
        .box .item .small{
            margin-top: 0.2rem;
        }
        .row .table{
            margin: 0.5rem 1rem;
            border: 1px solid #e2e2e2;
        }
        .row .table .head{
            display: -webkit-flex;
            display: -moz-flex;
            display: -o-flex;
            display: -ms-flex;
            display: flex;
            align-items: flex-start;
            justify-content: space-around;
            font-size: 0.8rem;
            color: #555;
            background: #e2e2e2;
            padding: 0.2rem 0;
        }
        .row .table p{
            width: 25%;
            padding: 0.2rem 0.4rem;
            border-left: 1px solid #e2e2e2;
            text-align: center;
        }
        .row .table p:nth-child(1){
            border-left: none;
            text-align: left;
        }
        .row .table .body{
            display: -webkit-flex;
            display: -moz-flex;
            display: -o-flex;
            display: -ms-flex;
            display: flex;
            align-items: flex-start;
            justify-content: space-around;
            font-size: 0.8rem;
            color: #000;
            border-top: 1px solid #e2e2e2;
        }
    </style>
</head>
<body class="admin">
<div class="row">
    <div class="title">概况</div>
    <div class="box">
        <div class="item">

            <div class="small">
                <?php foreach ($count AS $key => $value){ ?>
                    <p><?php echo $key; ?>：<?php echo $value; ?></p>

                <?php } ?>
            </div>
        </div>
        <div class="item">
            <p>pv/uv</p>
            <span><?php echo $user; ?></span>
        </div>


    </div>
</div>

</body>
</html>